//
//  BlackRoomViewController.m
//  shusheng
//
//  Created by rimi on 16/7/9.
//  Copyright © 2016年 yuying. All rights reserved.
//

#import "BlackRoomViewController.h"
#import "AnimatedTransitioning.h"
@interface BlackRoomViewController ()<UIViewControllerTransitioningDelegate>
@property(nonatomic,strong)UIView *soloView;        /**< 单人 */
@property(nonatomic,strong)UIView *soloChooseLeftView;
@property(nonatomic,strong)UIView *soloChooserightView;
@property(nonatomic,strong)UIView *multiplayerView; /**< 多人 */
@property(nonatomic,strong)UILabel *soloLabel;
@property(nonatomic,strong)UILabel *multiplayerLabel;
- (void)initializeInterface;  //初始化用户界面
@end

@implementation BlackRoomViewController
#pragma mark -- LifeCycle --
- (void)viewDidLoad {
    [super viewDidLoad];
    [self initializeInterface];
    self.transitioningDelegate = self;
    self.modalPresentationStyle = UIModalPresentationCustom;
    
 }

-(void)initializeInterface{
    [self.view addSubview:self.soloView];
    [self.view addSubview:self.multiplayerView];
    [self.view addSubview:self.multiplayerLabel];
    [self.view addSubview:self.soloLabel];
}

#pragma mark -- action --
- (IBAction)responBtn:(UIButton *)sender {
    NSLog(@"返回");
    [self dismissViewControllerAnimated:YES completion:nil];
}

-(void)tapPage{
//    [self.view addSubview:self.soloChooseLeftView];
//    [self.view addSubview:self.soloChooserightView];
    UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    EssayViewController *essayVc = [story instantiateViewControllerWithIdentifier:@"EssayViewController"];
    [self addChildViewController:essayVc];
    [self.view addSubview:essayVc.view];
}

-(void)multiplayer{
    [MBProgressHUD showSuccess:@"敬请期待!!"];
}

#pragma make -- UIViewControllerTransitioningDelegate --
-(id<UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source{
    
    return [AnimatedTransitioning transitionWithTransitionType:CircleSpreadTransitionTypePresent];
}

-(id<UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed{
    return [AnimatedTransitioning transitionWithTransitionType:CircleSpreadTransitionTypeDismiss];
}
#pragma mark -- getter --
-(UIView *)soloView{
    if (!_soloView) {
        _soloView = [[UIView alloc]init];
        _soloView.frame = CGRectMake(0, 64, CGRectGetWidth(self.view.bounds), (CGRectGetHeight(self.view.bounds)-64)/2);
        _soloView.backgroundColor = [UIColor cyanColor];
        
        UITapGestureRecognizer *tapGesturRecognizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapPage)];
        _soloView.userInteractionEnabled = YES;
        [_soloView addGestureRecognizer:tapGesturRecognizer];
    }
    return _soloView;
}
-(UIView *)soloChooseLeftView{
    if (!_soloChooseLeftView) {
        _soloChooseLeftView = [[UIView alloc]init];
        _soloChooseLeftView.bounds = CGRectMake(0, 0, CGRectGetWidth(self.view.bounds)/2, CGRectGetHeight(self.soloView.bounds));
        _soloChooseLeftView.center = CGPointMake(CGRectGetMidX(self.soloView.frame)/2, CGRectGetMidY(self.soloView.frame));
        _soloChooseLeftView.backgroundColor = [UIColor whiteColor];
    }
    return _soloChooseLeftView;
}
-(UIView *)soloChooserightView{
    if (!_soloChooserightView) {
        _soloChooserightView = [[UIView alloc]init];
        _soloChooserightView.bounds = CGRectMake(0, 0, CGRectGetWidth(self.view.bounds)/2, CGRectGetHeight(self.soloView.bounds));
        _soloChooserightView.center = CGPointMake(CGRectGetMidX(self.soloView.frame)*3/2, CGRectGetMidY(self.soloView.frame));
        _soloChooserightView.backgroundColor = [UIColor blackColor];
    }
    return _soloChooserightView;
}
-(UILabel *)soloLabel{
    if (!_soloLabel) {
        _soloLabel = [[UILabel alloc]init];
        _soloLabel.bounds = CGRectMake(0, 0, 100, 50);
        _soloLabel.center = CGPointMake(CGRectGetMidX(self.soloView.frame), CGRectGetMidY(self.soloView.frame));
        _soloLabel.text = @"单人开始";

    }
    return _soloLabel;
}
-(UIView *)multiplayerView{
    if (!_multiplayerView) {
        _multiplayerView = [[UIView alloc]init];
        _multiplayerView.frame = CGRectMake(0, CGRectGetMaxY(self.soloView.frame), CGRectGetWidth(self.view.bounds), (CGRectGetHeight(self.view.bounds)-64)/2);
        _multiplayerView.backgroundColor = [UIColor yellowColor];
        
        UITapGestureRecognizer *tapGesturRecognizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(multiplayer)];
        _multiplayerView.userInteractionEnabled = YES;
        [_multiplayerView addGestureRecognizer:tapGesturRecognizer];
    }
    return _multiplayerView;
}
-(UILabel *)multiplayerLabel{
    if (!_multiplayerLabel) {
        _multiplayerLabel = [[UILabel alloc]init];
        _multiplayerLabel.bounds = CGRectMake(0, 0, 100, 50);
        _multiplayerLabel.center = CGPointMake(CGRectGetMidX(self.multiplayerView.frame), CGRectGetMidY(self.multiplayerView.frame));
        _multiplayerLabel.text = @"多人开始";
    }
    return _multiplayerLabel;
}
@end
